<?php

$arr = array(
    "result"   => '', 
    "data"     => '', 
    "messages" => '', 
    "content"  => '', 
    );

if(isset($this->result)){
    $arr['result'] = $this->result;
}

if(isset($this->data)){
    $arr['data'] = $this->data;
}

if(isset($this->layout()->messages)){
    $arr['messages'] = $this->layout()->messages;
}

if(isset($this->layout()->content)){
    $arr['content'] = $this->layout()->content;
}

echo Zend_Json::encode($arr);

?>